package com.haixee.parkdemo.auth.controller;

import com.haixee.parkdemo.auth.entity.request.JobRequest;
import com.haixee.parkdemo.auth.service.JobService;
import com.haixee.parkdemo.common.response.ResResult;
import com.haixee.parkdemo.common.response.ResUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("job")
public class JobController {

    @Autowired
    private JobService jobService;

    @GetMapping("/all")
    public ResResult all() {
        return ResUtil.success(jobService.getAll());
    }

    @GetMapping("/roles")
    public ResResult roles(Integer jobId) {
        return ResUtil.success(jobService.getJobRole(jobId));
    }

    @PostMapping("/roles")
    public ResResult setRoles(@RequestBody JobRequest request) {

        jobService.setJobRoles(request.getJobId(), request.getRoleIdList());
        return ResUtil.success();
    }
}
